var http = require('../../utils/http.js');
var config = require('../../utils/config.js');
Page({
	data: {
		titList: "",
		img: "",
		activeKey: 0,
		value: "",
		imageURL: "",
		isok: "",
		records: [],
		categoryId: "",
	},
	// handleClick(e) {
	// 	// console.log(e.currentTarget.dataset.index,"12312313123");
	// 	this.setData({
	// 		isok: e.currentTarget.dataset.index
	// 	})
	// },
	onLoad: function () {
		http.request({
			url: "/category/categoryInfo",
			method: "get",
			data: {
				parentId: ""
			},
			callBack: res => {
				this.setData({
					titList: res,
					img: res[0].pic
				})
				console.log(this.data.titList, "111111111111111111");
			}
		});
		http.request({
			url: "/prod/pageProd",
			method: "get",
			data: {
				categoryId: 87
			},
			callBack: res => {
				// console.log(res.records[0]);
				this.setData({
					records: res.records
				})

				// console.log(this.conList);
			}
		});
	},
	handleClick(e) {
		// console.log(e.currentTarget.dataset,"wehruiyawuigdiuasdjkbfkasbdkfbakjsdfjkahs");
		this.setData({
			isok: e.currentTarget.dataset.index,
			indexId: e.currentTarget.dataset.index,
			img: e.currentTarget.dataset.item.pic,
			categoryId: e.currentTarget.dataset.item.categoryId
		})
		this.handleCon()
	},
	handleCon() {
		http.request({
			url: "/prod/pageProd",
			method: "get",
			data: {
				categoryId: this.data.categoryId
			},
			callBack: res => {
				// console.log(res.records[0]);
				this.setData({
					records : res.records
				})

				// console.log(this.conList);
			}
		});
	},
	handBan(e) {
		// console.log(e);
		if (e.currentTarget.dataset.item.prodId) {
			wx.navigateTo({
				url: `/pages/prod/prod?prodid=${e.currentTarget.dataset.item.prodId}`
			})
		}
	},
	handleSearch(){
		wx.navigateTo({
			url: `/pages/search-page/search-page`
		})
	},
})